DOORS memory problem

Hello,

ich have theis DXL program:
 

//
 
//List Informationen zu Ordnern und Modulen in eine csv - Datei aus.
 
// Deactivate timeout for script execution
pragma runLim, 0;
 
//Activate the Autodeclarefunction
//XFLAGS_ &= ~AutoDeclare_
 
// Constants
 
const string dummy[] = {};
const int modListWidth = 500;
const int modWidth = 150;
const int pathWidth = (modListWidth - modWidth)/2;
const int viewWidth = modWidth;
const int listLength = 20;
const int MINI_EXP_FP                       = 1;
const int MINI_EXP_LINK_MODS                = 2;
const int MINI_EXP_FORMAL_MODS              = 4;
const int MINI_EXP_DESCRIPTIVE_MODS         = 8;
const int MINI_EXP_SHOW_DELETED             = 16;
 
 
// Variables
 
DB copyDB;
DBE modListDBE;
DBE viewListDBE;
DBE modFrameDBE;
DBE removeModuleDBE;
DBE addModuleDBE;
DBE viewFrameDBE;
DBE okBtnDBE;
DBE applyBtnDBE;
DBE miniExplorerDBE;
DBE dbeBrowse;
DBE dbeDirectory;
DBE PfadablageDBE;
DBE TextfeldDBE;
DBE dbeFrame;
DBE ButtonframeDBE;
DBE TestDBE;
 
int dataRow;
int moduleCount = 0;
int nos = 0;
int nospseicher = 0;
int itemMask = MINI_EXP_FORMAL_MODS;
 
Item folderItem
 
string selectedPfadDOORS = "";
string res           = "";
string sep = "$";
string directoryName = "";
string Pfad_Name = "";
string log ="";
string result = "";
 
bool closeSrc;
 
Skip moduleList;
 
 
// Returns whether or not the selected item in the tree view matches the type of module the 
// tree view was created to be able to select
 
bool itemMatchesSelectedMask(Item itm) {
   bool matchesMask = false;
   
   if(type(itm) == "Formal" && ((itemMask & MINI_EXP_FORMAL_MODS) == MINI_EXP_FORMAL_MODS)) {
      matchesMask = true;
   }
   else if(type(itm) == "Link" && ((itemMask & MINI_EXP_LINK_MODS) == MINI_EXP_LINK_MODS)) {
      matchesMask = true;
   }
   else if(type(itm) == "Descriptive" && ((itemMask & MINI_EXP_DESCRIPTIVE_MODS) == MINI_EXP_DESCRIPTIVE_MODS)) {
      matchesMask = true;
   }
   
   return(matchesMask);
}
 
void addModuleToList(DBE clicked) {
 
   string selectedModule = getRealPath(dbSep get(miniExplorerDBE));
   
   Item i = item(selectedModule);
   Project p = getParentProject(i);
   bool moduleOpen = false;
   int currentRow;
   
}
 
string getWindowsFolder(string &dirPath)
{
    OleAutoObj  objDialog     = null
        OleAutoObj  objFolder     = null
        OleAutoObj  objFolderItem = null
        OleAutoArgs args          = create
        string      folderPath    = ""
        string      res           = ""
 
        dirPath = ""
 
        objDialog = oleCreateAutoObject("Shell.Application")
 
        if (null objDialog)
        {
                return("Failed to create dialog object")
        }
 
        put(args, 0)                         // always zero
        put(args, "Wählen sie einen Pfad:")  // title
        put(args, 0)                         // options
        //put(args, "c:\\temp")              // root folder
 
        res = oleMethod(objDialog, "BrowseForFolder", args, objFolder)
 
        if (null objFolder)
        {
                if (res "" != "")
                {
                        return("Failed to launch browser: " res)
                }
                else
                {
                        return("")
                }
        }
 
        res = oleGet(objFolder, "Self", objFolderItem)
 
        if (null objFolderItem)
        {
                return("Failed to get folder item: " res)
        }
 
        oleGet(objFolderItem, "Path", folderPath)
 
        dirPath = folderPath
        
        
        return(res)
}
 
// Adds a new item to the tree view.
void addItemToTree(DBE dbe, Item i) {
   string displayPath = getDisplayPath(i);
   
   // check if the path exists in the tree view
   if(exists(miniExplorerDBE, displayPath) == false) {
      // check that the item is not deleted or if it is, that the tree view was created with the option
      // to show deleted items.
      if(isDeleted(i) == false || (isDeleted(i) == true && ((itemMask & MINI_EXP_SHOW_DELETED) == MINI_EXP_SHOW_DELETED))) {
         // check item type
         if(type(i) == "Folder" || type(i) == "Project") {
            Icon iconOpen;
            Icon iconClosed;
            string sDummyEntry = displayPath dbSep dummyItem;
            
            // assign project or folder specific icons
            assignIcons(i, iconOpen, iconClosed);
            
            // add entry (plus dummy)
            insert(miniExplorerDBE, displayPath, iconClosed, iconOpen);
            insert(miniExplorerDBE, sDummyEntry, iconClosed, iconOpen);
         }
         else {
            if(itemMatchesSelectedMask(i)) {
               insert(miniExplorerDBE, displayPath, getIcon(i), getIcon(i));
            }
         }
      }
   }
}
 
// Opens the selected Project or Folder in the tree view and loads its containing items.
void displaySelectedBranch(DBE dbe, string sItemPath) {
   Folder fStart = folder(getRealPath(sItemPath));
   
   if(fStart != null) {
      Item i;
      
      for i in all fStart do {
         addItemToTree(miniExplorerDBE, i);
      }
   }
}
 
// DBE callback that fires when an element in the tree view is selected.
void doTreeSelect(DBE dbe) {
   string sel = getRealPath(dbSep get(miniExplorerDBE));
   
}
 
// DBE callback that fires when an item in the tree view is double clicked.
bool doTreeExpand(DBE dbe, string sItem) {
   string sItemPath = dbSep sItem;
   string sDummyItem = sItemPath dbSep dummyItem;
   
   // check status
   if(exists(miniExplorerDBE, sDummyItem) == true) {
      // remove dummy
      delete(miniExplorerDBE, sDummyItem);
   }
   
   // check status
   if(theCurrentView == DATABASE_VIEW) {
      // adjust view accordingly
      displaySelectedBranch(miniExplorerDBE, sItemPath);
   }
   else {
      Project prjOldRoot = getRootProject_();
      
      setRootProject_(project(getRootOfPath sItemPath));
      
      // adjust view accordingly
      displaySelectedBranch(miniExplorerDBE, sItemPath);
      
      setRootProject_(prjOldRoot);
   }
   
   return(true)
}
 
// Loads the tree view to start with the passed in folder opened.
void changeToStartFolder(Folder fStart) {
   if(!null fStart) {
      int i;
      
      // calculate max bound for loop
      int finish = length(rootName_(fStart));
      
      // prepare initial path
      string sFolderPath = ((theCurrentView == DATABASE_VIEW) ? dbDisplayRoot() : "");
      string sCharacter;
      
      // process string
      for(i = 0; i <= finish; i++) {
         // obtain character
         sCharacter = (rootName_(fStart))[i:i]
         
         // check status
         if(sCharacter == dbSep || i == finish) {
            // check status
            if(theCurrentView == PROJECT_VIEW && sFolderPath == dbSep) {
               continue;
            }
            
            // update explorer
            displaySelectedBranch(miniExplorerDBE, sFolderPath);
         }
         
         sFolderPath = sFolderPath sCharacter;
      }
      
      // update explorer
      set(miniExplorerDBE, sFolderPath);
   }
   else {
      // default to database level
      displaySelectedBranch(miniExplorerDBE, dbDisplayRoot());
      set(miniExplorerDBE, dbDisplayRoot());
   }
}
 
void addModuleToList(DBE clicked) {
 
   string modName;
   string selectedPfadDOORS = getRealPath(dbSep get(miniExplorerDBE));
   int currentRow;
   
   currentRow = noElems(modListDBE);
   insert(modListDBE, currentRow, selectedPfadDOORS);
   setCheck(modListDBE, currentRow, true)
   
  active(applyBtnDBE);
  }
 
void closeDB(DB dbox) {   
   hide(dbox);
   destroy(dbox);
   dbox = null;
}
 
void createReportLine(Item i)
{
 
        //Buffer result = create();
        
        ModuleVersion mv = moduleVersion(module fullName(i))
        ModuleProperties mp
        getProperties (mv, mp)
 
        result = stringOf(today) sep
        result = result name i sep
        result = result rootName_ i sep
        result = result uniqueID(i) sep
        
        AttrDef adCurrent = null
        adCurrent = find(mp, "Module Type")
        
        if (adCurrent == null){
                result =result "NULL" sep sep
        }
        else{
                string modType = mp."Module Type"
                result = result modType sep
                // Evaluate baselines for FI Modules only
                if(modType == "FI Module"){
                        Module currModule = read(fullName i, false, false)
                        Baseline b
                        for b in currModule do {
                                result =result (major b) "." (minor b) (suffix b) " @@ "
                        }
                        close(currModule, false)
                        result = result sep
                }
                else{
                        result = result sep
                }
        }
        
        result = result mp."Last Modified On" sep
        result = result mp."Last Modified By" sep
        
        result = result description i sep
        result = result getURL i sep
        
        result = result mp."Created On" sep
        result = result mp."Created By" sep
        
        result = result "\n"
        out << result;
        flush out;
        flushDeletions();
        //delete result;        
        
}
 
void processBar(Folder f)
                                {
                                for folderItem in f do {
                                        if(isDeleted(folderItem))
                                         continue
                                        if(type folderItem == "Formal"){
                                        nos++;
                                                }
                                        if(type folderItem == "Project"){
                                                processBar(folder(fullName folderItem));
                                                }
                                        if(type folderItem == "Folder"){
                                                processBar(folder(fullName folderItem));
                                                }
                                        }
}
 
void processFolder(Folder f)
                {            
                        for folderItem in f do {
                                if(isDeleted(folderItem))
                                 continue
                                if(type folderItem == "Formal"){
                                        moduleCount++
                                        progressStep ++nos
                                        createReportLine(folderItem)
                                }
                                if(type folderItem == "Project"){
                                        processFolder(folder(fullName folderItem))
                                }
                                if(type folderItem == "Folder"){
                                        processFolder(folder(fullName folderItem))
                                }
                                if (progressCancelled) {
                                                progressStop;
                                                log = log "Sie haben den Export bei " moduleCount " von " nospseicher " Modulen abgebrochen." "\n";     
                                                log = log "Die abgebrochene Exportdatei wurde gespeichert unter: " Pfad_Name "\n";  
                                                set(TextfeldDBE,log);
                                                //set(TextfeldDBE, "Sie haben den Export bei " moduleCount " von " nospseicher " Modulen abgebrochen. Die Exportdatei wurde gespeichert unter: " Pfad_Name );
                                                moduleCount = 0;
                                                nos = 0 ;
                                                halt;                           
                                }
 
                        }
                
                log = "Exportumfang  analysiert, export läuft" "\n" moduleCount " Module" " von insgesamt " nospseicher " exportiert." "\n" "Die Exportdatei wird erstellt nach: " Pfad_Name "\n";
                set(TextfeldDBE,log);
}   
                                
                                
void Exportstart(DB dbox) {
 
                set(TextfeldDBE,"");
 
                Pfad_Name = get PfadablageDBE;
 
                Buffer intro = create();
                
                Stream out = write(Pfad_Name);
 
                intro = "Created on"sep"Module Name"sep"Root Name"sep"UniqueID"sep"Module Type"sep"Baseline"sep"Last Modified On"sep"Last Modified By"sep"Description"sep"URL"sep"Created On"sep"Created By\n"
                
                out << intro;
                delete intro;
 
                int i = 0               
                selectedPfadDOORS = getColumnValue(modListDBE,  i,  0) 
                Folder f = folder(selectedPfadDOORS)
                log = "#SCRIPT arbeitet, bitte warten Sie. " "\n";
                set(TextfeldDBE,log);
                
                for (i < noElems(modListDBE); i++){
                set   (modListDBE, i,  1,  "Wird Analysiert");
                selectedPfadDOORS = getColumnValue(modListDBE,  i,  0) 
                Folder f = folder(selectedPfadDOORS)
                // Loop through folders and subfolder (recursive)
                processBar(Folder f);
                nospseicher = nos;
                set   (modListDBE, i,  1,  "Analysiert, warte auf Export");
                }
                
                log = log "Exportumfang wurde analysiert, keinen Fehler gefunden" "\n";     
                set(TextfeldDBE,log);
                progressStart(copyDB, "Export fortschritt", "" ,nos) ;
 
                nos = 0;                
                i = 0           
                for (i < noElems(modListDBE); i++){
                set   (modListDBE, i,  1,  "Wird Exportiert");
                selectedPfadDOORS = getColumnValue(modListDBE,  i,  0) 
                Folder f = folder(selectedPfadDOORS)
                processFolder(Folder f)
                set   (modListDBE, i,  1,  "Exportiert");
                }
                
                log = log "Exportdatei fertig gestellt: " "\n" "Datei liegt unter:" Pfad_Name "\n";
                set(TextfeldDBE,log);
                progressStop;
                
                moduleCount = 0;
                nos = 0 ;
                nospseicher = 0;
                i = 0;
} 
 
void deleteTest (DBE clicked){
//int selectedRow = get(modListDBE);
//string moduleName = getColumnValue(modListDBE, selectedRow, 1);
 
// Muss angepasst werden, Listview durchlauf löscher
int i = -1
 
        for (i < noElems(modListDBE); i++){
                delete(modListDBE, i);
                //setCheck(modListDBE, i, false) //für setCheck i=-1 Auskommentieren
                i =-1
        }
        inactive(applyBtnDBE);
        
}
 
 
void buildDB() {
   string projectName = "";
   Project projectRoot = null;
   
   copyDB = create("Exportscript für REQUEST", styleCentered);
 
        dbeFrame = frame(copyDB, "Exportscript", 400, 580);
        dbeFrame->"top"->"form"
        dbeFrame->"left"->"form"
        dbeFrame->"right"->"form"
        dbeFrame->"bottom"->"form"
   
   modFrameDBE = frame(copyDB, "Select DOORS Pfad für Export", 400, 420);
        modFrameDBE->"top"->"inside"->dbeFrame
        modFrameDBE->"left"->"inside"->dbeFrame
        modFrameDBE->"right"->"inside"->dbeFrame
        modFrameDBE->"bottom"->"unattached"
        
        ButtonframeDBE = frame(copyDB, "Buttons", 400 ,100 );
        ButtonframeDBE->"top"->"flush"->modFrameDBE
        ButtonframeDBE->"left"->"inside"->dbeFrame
        ButtonframeDBE->"right"->"inside"->dbeFrame
        ButtonframeDBE->"bottom"->"inside"->dbeFrame
        
 
   miniExplorerDBE = treeView(copyDB, treeViewOptionSorted, 0, 10);
        miniExplorerDBE->"top"->"inside"->modFrameDBE
        miniExplorerDBE->"left"->"inside"->modFrameDBE
        miniExplorerDBE->"right"->"inside"->modFrameDBE
        miniExplorerDBE->"bottom"->"unattached"       
        
   PfadablageDBE = fileName(copyDB, "Export to:", "C:/Documents and Settings/All Users/Desktop/" "Export.csv", "*.csv", "Excel Files", false)
        PfadablageDBE->"top"->"flush"->miniExplorerDBE
        PfadablageDBE->"left"->"inside"->modFrameDBE
        PfadablageDBE->"right"->"inside"->modFrameDBE
        PfadablageDBE->"bottom"->"unattached"
        
        modListDBE = listView(copyDB, listViewOptionCheckboxes | listViewOptionMultiselect, 400, 8, dummy)
        modListDBE->"top"->"flush"->PfadablageDBE
        modListDBE->"left"->"inside"->modFrameDBE
        modListDBE->"right"->"inside"->modFrameDBE
        modListDBE->"bottom"->"unattached"
        
   removeModuleDBE = button(copyDB, "Exportinhalt definieren", addModuleToList, true, 100);
        removeModuleDBE->"top"->"inside"->ButtonframeDBE
        removeModuleDBE->"left"->"inside"->ButtonframeDBE
        removeModuleDBE->"right"->"unattached"
        removeModuleDBE->"bottom"->"inside"->ButtonframeDBE
        
  TestDBE = button(copyDB, "Reset Exportliste", deleteTest, true, 100);
        TestDBE->"top"->"inside"->ButtonframeDBE
        TestDBE->"left"->"flush"->removeModuleDBE
        TestDBE->"right"->"unattached"
        TestDBE->"bottom"->"inside"->ButtonframeDBE
        
 
  TextfeldDBE = text(copyDB, "Logfenster", "",150, true);
        TextfeldDBE->"top"->"flush"->removeModuleDBE
        TextfeldDBE->"left"->"inside"->ButtonframeDBE
        TextfeldDBE->"right"->"inside"->ButtonframeDBE
        TextfeldDBE->"bottom"->"inside"->ButtonframeDBE
   
   applyBtnDBE = apply(copyDB, "Exportstart", Exportstart);
   close(copyDB, true, closeDB);
   
  inactive(applyBtnDBE);
   realize(copyDB);
   
   set(miniExplorerDBE, doTreeSelect);
   set(miniExplorerDBE, doTreeExpand);
   
   insertColumn(modListDBE,  0, "Project Pfad",  450, iconProject);
   insertColumn(modListDBE,  1, "Status",  130, iconNone);
   
   // check status
   if(theCurrentView == DATABASE_VIEW) {
      insert(miniExplorerDBE, dbDisplayRoot(), iconDatabase, iconDatabase);
   }
   else {
      projectRoot = getRootProject_();
      setRootProject_(null);
      
      // process database
      for projectName in database do {
         addItemToTree(miniExplorerDBE, item(dbSep projectName));
      }
      
      setRootProject_(projectRoot);
   }
   
   changeToStartFolder(current Folder);
  
}
 
 
   // Main
   buildDB();
   show(copyDB);

 


when i export a big Project the Memory will overflow, have anyone a idea what i can do?

Greets DJ

 


Mr.DJ - Thu Nov 24 06:43:46 EST 2011

Re: DOORS memory problem
Mathias Mamsch - Thu Nov 24 07:37:04 EST 2011

You might want to post large code like this as an attachment. This code has so many memory problems,
that you will need to invest some work to make it work on very large projects. Having scripts work
on large projects and handle a lot of data is not easy in DXL. The following rules apply (and are
violated by your code):
  • Do not use strings for processing attribute content (example: string result)
-> Use Buffers to read content, use combine for adding to another buffer
  • Never use strings for accumulating log information (example: string log, string result)
-> Use Buffers and += operator, add each string separately use no concatenation

That is all I see on a first glance, Regards, Mathias

Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Re: DOORS memory problem
Mr.DJ - Thu Nov 24 09:17:28 EST 2011

Hello,

ich have check the Code and the problem is thies part:
 

void createReportLine(Item i)
{
 
    Buffer result = create();
        
        ModuleVersion mv = moduleVersion(module fullName(i))
        ModuleProperties mp
        getProperties (mv, mp)
 
        result = stringOf(today) sep
        result +=  name i sep
        result +=  rootName_ i sep
        result +=  uniqueID(i) sep
        
        AttrDef adCurrent = null
        adCurrent = find(mp, "Module Type")
        
        if (adCurrent == null){
                result = "NULL" sep sep
        }
        else{
                string modType = mp."Module Type"
                result +=  modType sep
                // Evaluate baselines for FI Modules only
                if(modType == "FI Module"){
                        Module currModule = read(fullName i, false, false)
                        Baseline b
                        for b in currModule do {
                                result += (major b) "." (minor b) (suffix b) " @@ "
                        }
                        close(currModule, false)
                        result +=  sep
                }
                else{
                        result +=  sep
                }
        }
        
        result +=  mp."Last Modified On" sep
        result +=  mp."Last Modified By" sep
        
        result +=  description i sep
        result +=  getURL i sep
        
        result +=  mp."Created On" sep
        result +=  mp."Created By" sep
        
        result =  "\n"
        
        //out << result;
 
        delete result;  
        
}

 


I can check the full DB and the memory have a spread by 0,5k. But when i write to out then the memory will exhaust. I have create a Buffer und delete them but the memory will grow and grow.

Any idea?

Greetz DJ

 

Re: DOORS memory problem
Mathias Mamsch - Thu Nov 24 18:09:59 EST 2011

Mr.DJ - Thu Nov 24 09:17:28 EST 2011

Hello,

ich have check the Code and the problem is thies part:
 

void createReportLine(Item i)
{
 
    Buffer result = create();
        
        ModuleVersion mv = moduleVersion(module fullName(i))
        ModuleProperties mp
        getProperties (mv, mp)
 
        result = stringOf(today) sep
        result +=  name i sep
        result +=  rootName_ i sep
        result +=  uniqueID(i) sep
        
        AttrDef adCurrent = null
        adCurrent = find(mp, "Module Type")
        
        if (adCurrent == null){
                result = "NULL" sep sep
        }
        else{
                string modType = mp."Module Type"
                result +=  modType sep
                // Evaluate baselines for FI Modules only
                if(modType == "FI Module"){
                        Module currModule = read(fullName i, false, false)
                        Baseline b
                        for b in currModule do {
                                result += (major b) "." (minor b) (suffix b) " @@ "
                        }
                        close(currModule, false)
                        result +=  sep
                }
                else{
                        result +=  sep
                }
        }
        
        result +=  mp."Last Modified On" sep
        result +=  mp."Last Modified By" sep
        
        result +=  description i sep
        result +=  getURL i sep
        
        result +=  mp."Created On" sep
        result +=  mp."Created By" sep
        
        result =  "\n"
        
        //out << result;
 
        delete result;  
        
}

 


I can check the full DB and the memory have a spread by 0,5k. But when i write to out then the memory will exhaust. I have create a Buffer und delete them but the memory will grow and grow.

Any idea?

Greetz DJ

 

So you are saying, when you comment that line "out << result" out, then everything runs fine, but when you comment it in, then you will have memory exhaustion? What DOORS Version are you using? Regards, Mathias

Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Re: DOORS memory problem
Mathias Mamsch - Thu Nov 24 18:18:09 EST 2011

Mr.DJ - Thu Nov 24 09:17:28 EST 2011

Hello,

ich have check the Code and the problem is thies part:
 

void createReportLine(Item i)
{
 
    Buffer result = create();
        
        ModuleVersion mv = moduleVersion(module fullName(i))
        ModuleProperties mp
        getProperties (mv, mp)
 
        result = stringOf(today) sep
        result +=  name i sep
        result +=  rootName_ i sep
        result +=  uniqueID(i) sep
        
        AttrDef adCurrent = null
        adCurrent = find(mp, "Module Type")
        
        if (adCurrent == null){
                result = "NULL" sep sep
        }
        else{
                string modType = mp."Module Type"
                result +=  modType sep
                // Evaluate baselines for FI Modules only
                if(modType == "FI Module"){
                        Module currModule = read(fullName i, false, false)
                        Baseline b
                        for b in currModule do {
                                result += (major b) "." (minor b) (suffix b) " @@ "
                        }
                        close(currModule, false)
                        result +=  sep
                }
                else{
                        result +=  sep
                }
        }
        
        result +=  mp."Last Modified On" sep
        result +=  mp."Last Modified By" sep
        
        result +=  description i sep
        result +=  getURL i sep
        
        result +=  mp."Created On" sep
        result +=  mp."Created By" sep
        
        result =  "\n"
        
        //out << result;
 
        delete result;  
        
}

 


I can check the full DB and the memory have a spread by 0,5k. But when i write to out then the memory will exhaust. I have create a Buffer und delete them but the memory will grow and grow.

Any idea?

Greetz DJ

 

I don't get it: out is a local variable of ExportStart, still you are using it in 'createReportLine'? Is there maybe some global variable 'out' defined which will do something completely different with your buffer than you thought? I thought it might be a default stream but they are called cin and cout. I never experienced any problems with writing even large buffers to files. Regards, Mathias

Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Re: DOORS memory problem
llandale - Tue Nov 29 13:24:55 EST 2011

Mr.DJ - Thu Nov 24 09:17:28 EST 2011

Hello,

ich have check the Code and the problem is thies part:
 

void createReportLine(Item i)
{
 
    Buffer result = create();
        
        ModuleVersion mv = moduleVersion(module fullName(i))
        ModuleProperties mp
        getProperties (mv, mp)
 
        result = stringOf(today) sep
        result +=  name i sep
        result +=  rootName_ i sep
        result +=  uniqueID(i) sep
        
        AttrDef adCurrent = null
        adCurrent = find(mp, "Module Type")
        
        if (adCurrent == null){
                result = "NULL" sep sep
        }
        else{
                string modType = mp."Module Type"
                result +=  modType sep
                // Evaluate baselines for FI Modules only
                if(modType == "FI Module"){
                        Module currModule = read(fullName i, false, false)
                        Baseline b
                        for b in currModule do {
                                result += (major b) "." (minor b) (suffix b) " @@ "
                        }
                        close(currModule, false)
                        result +=  sep
                }
                else{
                        result +=  sep
                }
        }
        
        result +=  mp."Last Modified On" sep
        result +=  mp."Last Modified By" sep
        
        result +=  description i sep
        result +=  getURL i sep
        
        result +=  mp."Created On" sep
        result +=  mp."Created By" sep
        
        result =  "\n"
        
        //out << result;
 
        delete result;  
        
}

 


I can check the full DB and the memory have a spread by 0,5k. But when i write to out then the memory will exhaust. I have create a Buffer und delete them but the memory will grow and grow.

Any idea?

Greetz DJ

 

Mathias' observation about "out" is probably your main problem.

Once you converted "result" to a Buffer I don't see an exponential problem, but I do see these small ones:
  • "result" may better be declared globally and created at the top and deleted once when done. This will relieve the "create" function which is particularly slow if this function is called 10,000 times.
  • add "sep" separately to the buffer to reduce the small wasted concatenation.
    • .... result += uniqueID(i); result += sep
    • I don't recall but you may need to add a casting:
    • .... result += (string mp."Created On"); result += sep
  • It seems to me I've had trouble with LOTS of writing to output streams; I think writing 100,000 bytes once is a lot faster than writing 1,000 bytes 100 times. (This is definately true for "print" statements which slow down drastically as you get lots of them) I accumulate results in a huge global buffer and send it to the output file at the end. Sending it incrementally may make sense if your program is subject to aborting; so send interm results; close the file, and re-open it will let you figure out how far you got before the abort.

-Louie